import { createStore } from 'vuex'
import createPersistedState from 'vuex-persistedstate'
import home from './modules/home'
import user from './modules/user'
import app from './modules/app'

export default createStore({
  state: {},
  getters: {
    token: (state) => state.app.token,
    dialogVisible: (state) => state.app.dialogVisible,
    logStatus: (state) => state.app.logStatus
  },
  mutations: {},
  actions: {},
  modules: {
    app,
    home,
    user
  },
  plugins: [
    //默认情况下，vuex会在localStorage中保存数据
    createPersistedState({
      //本地存储名字
      key: 'juejin-client-web-storage',
      //指定需要存储的模块
      paths: ['user', 'home', 'app']
    })
  ]
})
